package com.hx.voice.recognition.auth.server.util.client;

import com.hx.voice.recognition.auth.server.configuration.KeyConfiguration;
import com.hx.zjb.security.auth.common.util.jwt.IJWTInfo;
import com.hx.zjb.security.auth.common.util.jwt.JWTHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * @descripe：client token生成工具类
 * @company：南京华讯方舟通讯设备有限公司
 * @author：zhoujinbing
 * @time：2019/6/14 10:52
 * @version：V1.0
 */
@Configuration
@Slf4j
public class ClientTokenUtil {

    @Value("${client.expire}")
    private int expire;

    @Autowired
    private KeyConfiguration keyConfiguration;

    public String generateToken(IJWTInfo ijwtInfo) throws Exception {
        return JWTHelper.generateToken(ijwtInfo,keyConfiguration.getServicePriKey(),expire);
    }

    public IJWTInfo getInfoFromToken(String token) throws Exception
    {
        return JWTHelper.getInfoFormToken(token,keyConfiguration.getServicePubKey());
    }




}